<script type="text/javascript">
$(document).ready(function(){
$("#propinsi_id").change(function(){
var val = $(this).val();

$.ajax({
                    type: "POST",
                    url: "<?php echo Yii::app()->createUrl('/MstPropinsi/getKota'); ?>",
                    data: "kd_propinsi="+val,
                    success: function(data){
                        
                        $("#kota_id").html(data);
                        
                    }
     });


});
});
</script>
<div class="form">

    <?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
	'id'=>'reg-health-policy-non-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
	'enableAjaxValidation'=>false,
)); ?>

    <p class="help-block">Fields with <span class="required">*</span> are required.</p>

    <?php echo $form->errorSummary($model); ?>
	<div class="row">
					<!--=== Validation Example 1 ===-->
					<div class="col-md-6">
						<div class="widget box">
							<div class="widget-header">
								<h4><i class="icon-reorder"></i> Registration Form</h4>
							</div>
							<div class="widget-content">
								<div style="width:400px;float:left;">
								
								<?php echo $form->textFieldControlGroup($model,'mst_client_id',array('style'=>'display:none','id'=>'clien','class'=>'form-control')); ?>
								<?php echo CHtml::textField('mst_client_id',MstClient::model()->findByPk($model->mst_client_id)->name,array('disabled'=>true,'id'=>'clien2','class'=>'form-control')); ?>
								</div>
								<div style="padding-top:22px;" class="col-md-2">
												<a data-toggle="modal" href="#myModal1" class="btn btn-warning btn-block">Find</a>
											</div><br /><br/><br/>

								<?php echo $form->dropDownListControlGroup($model,'mst_jns_asuransi_id',CHtml::listData(MstJnsAsuransi::model()->findAll(" 1=1 AND id not in (7,13,14) "), 'id','name'), array('class'=>'form-control',
								'ajax' => array(
									'type'=>'POST', 
									'url'=>Yii::app()->createUrl('mstJnsAsuransi/loadCompany'), //or $this->createUrl('loadcities') if '$this' extends CController
									'update'=>'#perusahaan', //or 'success' => 'function(data){...handle the data in the way you want...}',
								  'data'=>array('perusahaan_id'=>'js:this.value'),
								  ))); ?>

								<?php echo $form->dropDownListControlGroup($model,'mst_perusahaan_asuransi_id',CHtml::listData(MstPerusahaanAsuransi::model()->findAll(), 'id','name'), array('id'=>'perusahaan','class'=>'form-control')); ?>

								<?php echo $form->textFieldControlGroup($model,'policy_no',array('class'=>'form-control','maxlength'=>50)); ?>

								<?php echo $form->textFieldControlGroup($model,'start_periode',array('class'=>'form-control','data-mask'=>"99-99-9999")); ?>

								<?php echo $form->textFieldControlGroup($model,'end_periode',array('class'=>'form-control','data-mask'=>"99-99-9999")); ?>

								
							</div>
						</div>
						<!-- /Validation Example 1 -->
					</div>
					
					<!--=== Validation Example 1 ===-->
					<div class="col-md-6">
						<div class="widget box">
							<div class="widget-header">
								<h4><i class="icon-reorder"></i> Registration Form</h4>
							</div>
							<div class="widget-content">
								
								<?php echo $form->dropDownListControlGroup($model, 'id_cabang', array(1 => 'Jakarta', 2 => 'Medan'), array('class'=>'form-control input-width-medium')); ?>

								<?php echo $form->dropDownListControlGroup($model,'mst_marketing_id',CHtml::listData(MstMarketing::model()->findAll(array('order'=>'id')), 'id', 'name'), array('prompt'=>'Pilih Marketing','class'=>'form-control')); ?>

								<?php echo $form->textAreaControlGroup($model,'remarks',array('class'=>'form-control','span'=>8)); ?>

								<?php echo $form->dropDownListControlGroup($model,'mst_currency_id',CHtml::listData(MstCurrency::model()->findAll(array('order'=>'id')), 'id', 'name'), array('class'=>'form-control')); ?>

								 <?php
			$installment = array();
			for($i=1;$i<=12;$i++){
				$installment[$i] = $i;
			}
			?>
			<?php echo $form->dropDownListControlGroup($model,'jml_installment',$installment,array('class'=>'form-control input-width-medium')); ?>
							</div>
						</div>
						<!-- /Validation Example 1 -->
					</div>
					</div>
					<div class="row">
					<!--=== Validation Example 1 ===-->
					<div class="col-md-12">
						<div class="widget box">
							<div class="widget-header">
								<h4><i class="icon-reorder"></i> Insured Object</h4>
							</div>
							<div class="widget-content">
							
								
					            <?php //echo $form->textFieldControlGroup($model,'insured_object',array('class'=>'form-control','maxlength'=>50)); ?>

					            <?php echo $form->textAreaControlGroup($model,'insured_object',array('class'=>'form-control','maxlength'=>50)); ?>

								<?php echo $form->textAreaControlGroup($model,'address',array('class'=>'form-control','maxlength'=>50)); ?>

								<?php echo $form->textFieldControlGroup($model,'sum_insured',array('class'=>'form-control','value'=>'0')); ?>


								<?php echo $form->dropDownListControlGroup($model,'province_id',CHtml::listData(MstPropinsi::model()->findAll(array('order'=>'id')), 'id', 'nm_propinsi'),
				            	array('class'=>'form-control', 'prompt'=>'Pilih Propinsi',
				            		'value'=>'0',
									'id'=>'propinsi_id')); ?>

								<?php
								if($model->isNewRecord){
								?>	
								
								<?php echo $form->dropDownListControlGroup($model,'city_id',CHtml::listData(MstCity::model()->findAll('id_propinsi=0'), 'id', 'nm_city'),array('class'=>'form-control', 'prompt'=>'Pilih Kota','id'=>'kota_id')); ?>
								
								<?php
								}else{
								?>
											
								<?php echo $form->dropDownListControlGroup($model,'city_id',CHtml::listData(MstCity::model()->findAll('id_propinsi='.$model->province_id), 'id', 'nm_city'),array('class'=>'form-control', 
								'prompt'=>'Pilih Kota',
								'id'=>'kota_id',
								'options' => array($model->city_id=>array('selected'=>true)),
								)); ?>

								<?php
								}
								?>	


								

								
				</div>
						</div>
						<!-- /Validation Example 1 -->
					</div>
	
	
	
	</div>
            

        <div class="form-actions">
        <?php echo TbHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',array(
		    'color'=>TbHtml::BUTTON_COLOR_PRIMARY,
		    'size'=>TbHtml::BUTTON_SIZE_LARGE,
		)); ?>
    </div>

    <?php $this->endWidget(); ?>

</div><!-- form -->


											

											<!-- Modal dialog -->
											<div class="modal fade" id="myModal1">
												<div class="modal-dialog">
													<div class="modal-content">
														<div class="modal-header">
															<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
															<h4 class="modal-title">Find Client</h4>
														</div>
														<div class="modal-body">
														<?php
														Yii::app()->clientScript->registerScript('search', "
														$('.search-form form').keyup(function(){
															$('#mst-client-grid').yiiGridView('update', {
																data: $(this).serialize()
															});
															return false;
														});
														$('#selek').click(function(){
															$('#clien2').val($('input[name=\'radioButton2\']:checked').attr('nama'));
															$('#clien').val($('input[name=\'radioButton2\']:checked').val());
														});
														");
														?>
															<?php $this->widget('bootstrap.widgets.TbGridView',array(
																	'id'=>'mst-client-grid',
																	'dataProvider'=>$model2->search3(),
																	'filter'=>$model2,
																	'columns'=>array(
																		'client_number',
																		'name',
																		array(
																				'name'=>'.',
																				'value'=>'CHtml::radioButton("radioButton2", "",array("value"=>$data->id,"nama"=>$data->name,"cn"=>$data->client_number, "id"=>"rad2"))',
																				'type'=>'raw',
																				'filter'=>false,
																		),
																	),
																)); ?>
														</div>
														<div class="modal-footer">
															<button type="button" id="selek" class="btn btn-default" data-dismiss="modal">Select</button>
														</div>
													</div><!-- /.modal-content -->
												</div><!-- /.modal-dialog -->
											</div><!-- /.modal -->

									





